<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    var names = ["abc", "cba", "nba", "mba"]
    console.log(names.length)

    // length属性是可写的-扩容,截取
    names.length = 10
    console.log(names)
    names.length = 2
    console.log(names)
    names.length = 0
    console.log(names)

    
    var names = ["abc", "cba", "nba", "mba"]
    // 数组的遍历
    for (var i = 0; i < names.length; i++) {
      console.log(names[i])
    }

    for (var index in names) {
      console.log(index, names[index])
    }

    for (var name of names) {
      console.log(name)
    }
  </script>
</body>

</html>